﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace calendar
{
public class Day
{
    protected Day(int value)
    {
        m_value = value;
    }

    public int getValue()
    {
        return m_value;
    }

    public Day getNextDay()
    {
        int value = m_value + 1;
        if (value > 7) {
            value = 1;
        }
        return getInstance(value);
    }

    public static Day getInstance(int value)
    {
        Day result = null;
        if (value >= 0 && value < DAY_ARRAY.Length) {
            result = DAY_ARRAY[value];
        }
        return result;
    }

    public override string ToString()
    {
        return m_value.ToString();
    }

    private int m_value;

    public static readonly Day SUNDAY = new Day(1);
    public static readonly Day MONDAY = new Day(2);
    public static readonly Day TUESDAY = new Day(3);
    public static readonly Day WEDNESDAY = new Day(4);
    public static readonly Day THURSDAY = new Day(5);
    public static readonly Day FRIDAY = new Day(6);
    public static readonly Day SATURDAY = new Day(7);

    private static readonly Day[] DAY_ARRAY = {
        null,
        SUNDAY,
        MONDAY,
        TUESDAY,
        WEDNESDAY,
        THURSDAY,
        FRIDAY,
        SATURDAY
    };
}
}
